//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#include <bsp.h>
#include <regs.h>
#include "ite8712.h"
#include "ite8172.h"

static void LPCEnterMBPnP(void)
{
    int i;
    unsigned char key[4] = {0x87, 0x01, 0x55, 0x55};

    for (i = 0; i < 4; i++)
    {
        Outb(KSEG1ADDR(LPC_KEY_ADDR), key[i]);
    }
}

static void LPCExitMBPnP(void)
{
    Outb(KSEG1ADDR(LPC_KEY_ADDR), 0x02);
    Outb(KSEG1ADDR(LPC_DATA_ADDR), 0x02);
}

void BspLPCSetConfig(char LdnNumber, char Index, char data)
{
    LPCEnterMBPnP();                // Enter IT8712 MB PnP mode
    Outb(KSEG1ADDR(LPC_KEY_ADDR), 0x07);
    Outb(KSEG1ADDR(LPC_DATA_ADDR), LdnNumber);
    Outb(KSEG1ADDR(LPC_KEY_ADDR), Index);
    Outb(KSEG1ADDR(LPC_DATA_ADDR), data);
    LPCExitMBPnP();
}

char BspLPCGetConfig(char LdnNumber, char Index)
{
    char cRtn;

    LPCEnterMBPnP();                // Enter IT8712 MB PnP mode
    Outb(KSEG1ADDR(LPC_KEY_ADDR), 0x07);
    Outb(KSEG1ADDR(LPC_DATA_ADDR), LdnNumber);
    Outb(KSEG1ADDR(LPC_KEY_ADDR), Index);
    cRtn = Inb(KSEG1ADDR(LPC_DATA_ADDR));
    LPCExitMBPnP();

    return cRtn;
}

